﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace YinLong.ReportEx
{
    public partial class FrmReportPreView : Form
    {
        public FrmReportPreView()
        {
            InitializeComponent();
        }
        private FastReport.Report _report;

        public FastReport.Report Report
        {
            get { return _report; }
            set { _report = value; }
        }
        private string _reportName;

        public string ReportName
        {
            get { return _reportName; }
            set { _reportName = value; }
        }
        public FrmReportPreView(FastReport.Report report)
            : this()
        {
            this.Report = report;
        }
        public FrmReportPreView(FastReport.Report report, string reportname)
            : this(report)
		{
			this.ReportName = reportname;
		}
        private void previewControl1_Load(object sender, EventArgs e)
        {

        }

        private void rePortPreView_Load(object sender, EventArgs e)
        {
            
            Report.Preview = this.previewControl;
            Report.Prepare();
            Report.ShowPrepared();
            
        }

        private void rePortPreView_FormClosed(object sender, FormClosedEventArgs e)
        {
            Report.Dispose();
        }

        private void previewContro_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F12)
            {
                FrmReportDesigner desingner = new FrmReportDesigner(this.Report);
                desingner.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                desingner.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                desingner.ShowDialog();
            }
        }

        private void rePortPreView_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F12)
            {
                new FrmReportDesigner(this.Report)
                {
                    StartPosition = FormStartPosition.CenterScreen,
                    WindowState = FormWindowState.Maximized
                }.ShowDialog();
            }
        }      
    }
}
